package com.xlt.activiti.one;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;

// 流程定义部署到表中
public class ActivitiDeployment {

    public static void deployment (){
       deployment("bpmn/leave.bpmn","bpmn/leave.png");
    }


    public static void deployment (String bpmnPath,String pngPath){
        // 1.创建ProcessEngine对象
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        // 2.得到repositoryService 实例
        RepositoryService repositoryService = processEngine.getRepositoryService();

        // 3.进行部署
        Deployment deployment = repositoryService.createDeployment()
                .addClasspathResource(bpmnPath)
                .addClasspathResource(pngPath)
                .name("普通员工请假流程")
                .deploy();// 部署

        // 4.输出部署的一些信息
        System.out.println(deployment.getName());
        System.out.println(deployment.getId());
    }
}
